how to loop through an array in js